package com.example.ai.config.tools;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CurrentTimeTool {

    @Tool(description = "Get current local date and time for a given GMT zone (e.g., GMT+8, GMT-1).")
    public static String getCurrentTime(@ToolParam(description = "The GMT zone ID, like GMT+8、GMT-5") String gmtZoneId) {
        ZonedDateTime zonedDateTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneId.of(gmtZoneId));
        String time = zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        log.info("getLocalTime zone:{} time:{}", gmtZoneId, time);
        return time;
    }
}
